/**
 * @file 01_stat_lstat.c
 * @author stat和lstat的区别
 * @brief
 * @version 0.1
 * @date 2023-03-06
 *
 * @copyright Copyright (c) 2023
 *
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>

int main(void)
{
    const char* file_path = "/usr/bin/python3";
    struct stat st;

    //st_mode中包含了文件类型、文件权限
    stat(file_path, &st);
    printf("mode: %o, size: %ld, is_regular: %d, is_link: %d\n", st.st_mode, st.st_size, S_ISREG(st.st_mode), S_ISLNK(st.st_mode));

    lstat(file_path, &st);
    printf("mode: %o, size: %ld, is_regular: %d, is_link: %d\n", st.st_mode, st.st_size, S_ISREG(st.st_mode), S_ISLNK(st.st_mode));

    return 0;
}
